Creating Shadows

One feature, which applies to light source shaders but not to shaders of other classes, is the specification, creation and manipulation of shadows.

 

Of the six light sources supplied, distant, point, projector and spot light sources are able to cast shadows. Ambient and eye light sources do not cast shadows.

 

solidThinking supports shadowing in two different methods: shadow mapping and shadow ray casting. Note, however, that the shadow ray casting technique is only used by the ray tracer renderer.

 

The shadow ray casting works by following rays from a point on an object's surface toward light sources. Thus, it establishes whether or not there is a direct line of sight from the point to a given light source, and if it is lit by, or in shadow from, the source.

 

The shadow mapping technique involves shadow information for each light source that is able to cast shadows. This information may then be applied in a view-independent manner to subsequent images that are rendered. The properties of the shadows are specified by means of some of the arguments to the corresponding light source instance. Before a light source is able to cast shadows using this method, the preprocessing of the shadow data must be undertaken at the explicit direction of the application program. If any changes are made to the specification of the light source that affect the shadows, then the preprocessing of shadow data must be repeated.

 

The ray casting technique can only produce hard-edged shadows, which tend to detract from the realism of an image. On the contrary, the shadow mapping technique is capable of producing shadows with softened edges.

 

 The technique that is applied is determined from the 'resolution' value of the light shader. The resolution of shadowing is set for each light source individually using the shader argument "shadow resolution". If this value is set to zero for a light source, then shadowing from that source will be calculated using ray casting, producing hard-edged shadows.

 

When light passes through objects that are semi-transparent, you expect light to be partially occluded. For example, sunlight passing through a stained-glass window can produce a multi-colored 'shadow' on the floor.

 

solidThinking can reproduce this sort of effect, when shadows are produced using ray-casting (i.e., the light sources involved must be declared to produce ray-cast shadows by setting the "shadow resolution" shader argument to zero). The shadow-mapping technique is not adequate to provide this effect, and it will produce shadows as if the object were completely opaque.

 

When using ray-casting, a surface rendered using a "plain" colored transparency will cast shadows that are changed in hue as if the light had travelled through a colored medium.

 

On the other hand, a surface with many holes (as would be the case if the "eroded" transparency shader were used) will result in a mottled shadow being cast.

 

A "wrapped image" transparency shader will result in the image being used to cast shadows. This is how the effect of stained-glass, or windows with frames within the main shape, can be achieved without complicated modeling.

 

While it is possible to create some very interesting effects using this technique, keep in mind that it is very computationally intensive.

 

 

See also: